package kr.ac.sch.cs.HelloBabyServer;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.EditText;
import android.widget.Toast;

public class RobotSocket {

	/**
	 * @uml.property  name="tab1_array" multiplicity="(0 -1)" dimension="2"
	 */
	private String[][] tab1_array;
	/**
	 * @uml.property  name="tab1_string" multiplicity="(0 -1)" dimension="1"
	 */
	private String[] tab1_string;
	/**
	 * @uml.property  name="mContext"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	private Context mContext;
	/**
	 * @uml.property  name="edittext"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	private EditText edittext;
	
	public static int PARENT_CONTENT_1 = 0;
	public static int PARENT_CONTENT_2 = 1;
	public static int PARENT_CONTENT_3 = 2;
	
	public static int ROBOT_CONTROL_1 = 0;
	public static int ROBOT_CONTROL_2 = 1;
	public static int ROBOT_CONTROL_3 = 2;
	public static int ROBOT_CONTROL_4 = 3;
	public static int ROBOT_CONTROL_5 = 4;
	public static int ROBOT_CONTROL_6 = 5;
	
	public RobotSocket(Context context, EditText et) {
		this.mContext = context;
		this.edittext = et;
		init();
	}
	
	public void sendParentData(int i) {
		final CharSequence[] items = (CharSequence[]) tab1_array[i];
		
		AlertDialog.Builder d = new AlertDialog.Builder(mContext);
		d.setTitle(tab1_string[i]);
		d.setItems(items, new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				//Toast.makeText(mContext, items[which], Toast.LENGTH_SHORT).show();
				edittext.setText(items[which]);
			}
		});
		d.show();
	}
	
	public void sendRobotData(int i) {
		
	}
	
	public void sendRobotContent(int i) {
		
	}
	
	public void init() {
		tab1_array = new String[3][];
		tab1_string = new String[3];
		
		tab1_array[0] = mContext.getResources().getStringArray(R.array.tab1_btn1); 
		tab1_array[1] = mContext.getResources().getStringArray(R.array.tab1_btn2);
		tab1_array[2] = mContext.getResources().getStringArray(R.array.tab1_btn3);
		
		tab1_string[0] = mContext.getResources().getString(R.string.tab1_btn1);
		tab1_string[1] = mContext.getResources().getString(R.string.tab1_btn2);
		tab1_string[2] = mContext.getResources().getString(R.string.tab1_btn3);
	}
}
